package webserver.bank;

import java.io.IOException;
import java.rmi.RemoteException;
import java.util.HashMap;

import std.bank.Account;
import std.bank.Bank;

public class BankRPC implements Bank
{
	HashMap<String, Account> accountMap = new HashMap<String, Account>();
	String className = "std.bank.BankImpl";
	ClientStub client;

	public BankRPC()
	{
		try
		{
			Object[] parameterValues = {};
			Class<?>[] parameterTypes = {};
			client = new ClientStub(className, parameterTypes, parameterValues);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}

	public Account getAccount(String name) throws RemoteException
	{
		String methodName = "getAccount";
		Object[] parameterValues = { name };
		Class<?>[] paramaterTypes = { name.getClass() };
		int objectref = Integer.parseInt((String) client.performMethodCall(
				className, methodName, paramaterTypes, parameterValues));

		return new AccountRPC(objectref);
	}

}
